﻿<?php



 $data=' {
       "button":[{
           "name":"新品热卖",
           "sub_button":[
           {  
               "type":"view",
               "name":"热卖女装",
               "url":"http://dlshop.dliansoft.com/index.php/Mobile/Shop/index/type/indexwoman.html?dltoken=wxcd3cc358923b015c"
            },
            {
               "type":"view",
               "name":"热卖男装",
               "url":"http://dlshop.dliansoft.com/index.php/Mobile/Shop/index/type/indexman.html?dltoken=wxcd3cc358923b015c"
            }] 
       },

     {  

          "type":"view",

          "name":"爆款秒杀",

          "url":"http://dlshop.dliansoft.com/index.php/Mobile/Activity/flash_list/?dltoken=wxcd3cc358923b015c"

      },
      {
           "name":"个人中心",
           "sub_button":[
           {
              "type":"view",
              "name":"玩转七夕",
              "url":"http://dlshop.dliansoft.com/index.php/Mobile/Draw/index/id/6.html?dltoken=wxcd3cc358923b015c"
           },
            {
               "type":"view",
               "name":"会员中心",
               "url":"http://dlshop.dliansoft.com/index.php/Mobile/User/index?dltoken=wxcd3cc358923b015c"
            },
            {
               "type":"view",
               "name":"会员卡",
               "url":"http://dlshop.dliansoft.com/index.php/Mobile/User/mycode?dltoken=wxcd3cc358923b015c"
            },
           {  
               "type":"view",
               "name":"会员注册",
               "url":"http://dlshop.dliansoft.com/index.php/Mobile/User/userinfo?dltoken=wxcd3cc358923b015c"
            }]
       }]

 }';

 

  /*{  

          "type":"view",

          "name":"最美的您",

          "url":"http://dlshop.dliansoft.com/index.php/Mobile/Interact/vote_view/voteid/24/moban/2.html?dltoken=wxcd3cc358923b015c"

      }*/

 //定义创建菜单函数

function createMenu($data){

 $access_token='JDKWEN_V97cLrdJW5GjmOemYQA4aOVgAswU6_WU0CiWxU8HyoRrSVutuk_oFhq07Lfh_7VjY-XeF9Wsjd03ymy7q0PIw8c1vvKJAs1EHEgjeGfo11b81QPhGL5bAhSJKVNBjAIAPHV';

 $ch = curl_init();

 curl_setopt($ch, CURLOPT_URL, "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=".$access_token);

 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");

 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);

 curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');

 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

 curl_setopt($ch, CURLOPT_AUTOREFERER, 1);

 curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

 $tmpInfo = curl_exec($ch);

 if (curl_errno($ch)) {

  return curl_error($ch);

 }

 curl_close($ch);

 return $tmpInfo;

}


 //获取token

    function getToken(){

        $APPID='wxcd3cc358923b015c';//微信公众号AppID

        $APPSECRET='55fd2b7a8eeec2caf4d29f9b6a97a01e';//微信公众号AppSecret

        $urlstr='https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.$APPID.'&secret='.$APPSECRET;

        $res = file_get_contents($urlstr);

        $resarr=json_decode($res,true);

        return  $resarr['access_token'];

        define('ACCESS_TOKEN',$resarr['access_token']);



      }

//创建菜单



echo createMenu($data);